﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BIZ;
using DAL;

namespace SinhNhat
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                txtUsername.Focus();
            }
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            btnLogin.Click += new EventHandler(btnLogin_Click);
        }

        void btnLogin_Click(object sender, EventArgs e)
        {
            AccountBIZ accountBIZ = new AccountBIZ();
            var account = accountBIZ.Login(txtUsername.Text, txtPass.Text);

            if (account == null)
            {
                lblError.Visible = true;
            }
            else
            {
                Session["account"] = account;
                Response.Redirect("/admin/Manager.aspx");
            }
        }
    }
}